package com.chinasofti.tcp2;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;
public class ClientDemo {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1",10000);
        OutputStream os = socket.getOutputStream();
        os.write("hello".getBytes());
        //关闭输出流
        socket.shutdownOutput();//仅关闭输出流，对socket没有影响
        //接收服务端反馈
        BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        String line ;
        while ((line =br.readLine())!=null){
            System.out.println(line);
        }
        br.close();
        os.close();
        socket.close();
    }
}
